#include "asm.h"
#include "regdef.h"
#include "inst_test.h"

LEAF(n15_st_w_test)
    
    addi.w s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_ST_W(0x61754443, 0x800d77a0,  0x714,  0x714, 0x61754443)
    TEST_ST_W(0x5c4fb45a, 0x800d4aac,  0x76c,  0x76c, 0x5c4fb45a)
    TEST_ST_W(0x14908300, 0x800d4ae8,  0x5d8,  0x5d8, 0x14908300)
    TEST_ST_W(0x516da739, 0x800d60cc, -0x7b0, -0x7b0, 0x516da739)
    TEST_ST_W(0x85675a34, 0x800d5510,  0x3b0,  0x3b0, 0x85675a34)
    TEST_ST_W(0x0e4dac98, 0x800db040,  0x400,  0x400, 0x0e4dac98)
    TEST_ST_W(0xd9c6eddb, 0x800d7180,  0x2e0,  0x2e0, 0xd9c6eddb)
    TEST_ST_W(0x5753dd01, 0x800d2ca0,  0x280,  0x280, 0x5753dd01)
    TEST_ST_W(0xe543b9f3, 0x800d331c,  0x6b8,  0x6b8, 0xe543b9f3)
    TEST_ST_W(0x4726aca2, 0x800d6cf8,  0x570,  0x570, 0x4726aca2)
    TEST_ST_W(0xb022040a, 0x800d0800, -0x594, -0x594, 0xb022040a)
    TEST_ST_W(0x5ca0fd00, 0x800d9834,  0x570,  0x570, 0x5ca0fd00)
    TEST_ST_W(0x063ba000, 0x800d1c64,  0x4fc,  0x4fc, 0x063ba000)
    TEST_ST_W(0xc2268cfe, 0x800d81e8,  0x554,  0x554, 0xc2268cfe)
    TEST_ST_W(0x1611444c, 0x800d0484, -0x170, -0x170, 0x1611444c)
    TEST_ST_W(0x33cc6f2a, 0x800d71dc,  0x230,  0x230, 0x33cc6f2a)
    TEST_ST_W(0xc2b46f21, 0x800d1388,  0x664,  0x664, 0xc2b46f21)
    TEST_ST_W(0x63a86040, 0x800d02a8, -0x450, -0x450, 0x63a86040)
    TEST_ST_W(0xe08d45d0, 0x800d1d14, -0x254, -0x254, 0xe08d45d0)
    TEST_ST_W(0xf3839208, 0x800d5308,  0x06c,  0x06c, 0xf3839208)
    TEST_ST_W(0x4268fd38, 0x800d3f00,  0x0c0,  0x0c0, 0x4268fd38)
    TEST_ST_W(0x12816280, 0x800d1b94, -0x760, -0x760, 0x12816280)
    TEST_ST_W(0x5404b496, 0x800d1698, -0x178, -0x178, 0x5404b496)
    TEST_ST_W(0xf11c1c02, 0x800d1de0, -0x438, -0x438, 0xf11c1c02)
    TEST_ST_W(0x31090da2, 0x800d9400,  0x150,  0x150, 0x31090da2)
    TEST_ST_W(0x94809b50, 0x800d27c8,  0x2c0,  0x2c0, 0x94809b50)
    TEST_ST_W(0xff1ed37c, 0x800d1488, -0x29c, -0x29c, 0xff1ed37c)
    TEST_ST_W(0x5e23d200, 0x800da074,  0x258,  0x258, 0x5e23d200)
    TEST_ST_W(0x68831248, 0x800d63ec,  0x540,  0x540, 0x68831248)
    TEST_ST_W(0x4558e910, 0x800d0cc0,  0x38c,  0x38c, 0x4558e910)
    TEST_ST_W(0xc98327b0, 0x800d04e0, -0x5f8, -0x5f8, 0xc98327b0)
    TEST_ST_W(0xfea2f1ad, 0x800d1b68, -0x514, -0x514, 0xfea2f1ad)
    TEST_ST_W(0xac52b354, 0x800d0000, -0x324, -0x324, 0xac52b354)
    TEST_ST_W(0x4f612db4, 0x800d0000,  0x474,  0x474, 0x4f612db4)
    TEST_ST_W(0x81e4a52c, 0x800d0000,  0x370,  0x370, 0x81e4a52c)
    TEST_ST_W(0x6b615254, 0x800d0000,  0x79c,  0x79c, 0x6b615254)
    TEST_ST_W(0x2447d85d, 0x800d0000,  0x790,  0x790, 0x2447d85d)
    TEST_ST_W(0x8dde1c20, 0x800d0000,  0x37c,  0x37c, 0x8dde1c20)
    TEST_ST_W(0xcf304a09, 0x800d0000, -0x060, -0x060, 0xcf304a09)
    TEST_ST_W(0x431f45e2, 0x800d0000, -0x3a8, -0x3a8, 0x431f45e2)
    TEST_ST_W(0x99db9a50, 0x800d0000,  0x348,  0x348, 0x99db9a50)
    TEST_ST_W(0xe73f0fdc, 0x800d0000, -0x7e8, -0x7e8, 0xe73f0fdc)
    TEST_ST_W(0x450bbdc0, 0x800d0000,  0x528,  0x528, 0x450bbdc0)
    TEST_ST_W(0xc0c7c830, 0x800d0000, -0x780, -0x780, 0xc0c7c830)
    TEST_ST_W(0x8006ca23, 0x800d0000,  0x530,  0x530, 0x8006ca23)
    TEST_ST_W(0x40047d98, 0x800d0000, -0x518, -0x518, 0x40047d98)
    TEST_ST_W(0xc95de720, 0x800d0000,  0x780,  0x780, 0xc95de720)
    TEST_ST_W(0xd0476900, 0x800d0000, -0x320, -0x320, 0xd0476900)
    TEST_ST_W(0x873f383a, 0x800d0000,  0x4b8,  0x4b8, 0x873f383a)
    TEST_ST_W(0x50d54ce0, 0x800d0000, -0x7e0, -0x7e0, 0x50d54ce0)
    TEST_ST_W(0x8502ea18, 0x800d0000, -0x010, -0x010, 0x8502ea18)
    TEST_ST_W(0x09f2b630, 0x800d0000, -0x5dc, -0x5dc, 0x09f2b630)
    TEST_ST_W(0xe8079b47, 0x800d0000,  0x4e0,  0x4e0, 0xe8079b47)
    TEST_ST_W(0x5de6e330, 0x800d0000,  0x000,  0x000, 0x5de6e330)
    TEST_ST_W(0xbf637404, 0x800d0000,  0x000,  0x000, 0xbf637404)
    TEST_ST_W(0x99227ac0, 0x800d0000,  0x000,  0x000, 0x99227ac0)
    TEST_ST_W(0xddecd270, 0x800d0000,  0x000,  0x000, 0xddecd270)
    TEST_ST_W(0x06a06018, 0x800d0000,  0x000,  0x000, 0x06a06018)
    TEST_ST_W(0xf428d0c8, 0x800d0000,  0x000,  0x000, 0xf428d0c8)
    TEST_ST_W(0xa6ce33ec, 0x800d0000,  0x000,  0x000, 0xa6ce33ec)
    TEST_ST_W(0xa7813bc0, 0x800d0000,  0x000,  0x000, 0xa7813bc0)
    TEST_ST_W(0x72440e8c, 0x800d0000,  0x000,  0x000, 0x72440e8c)
    TEST_ST_W(0xa4130340, 0x800d0000,  0x000,  0x000, 0xa4130340)
    TEST_ST_W(0xb6ca0800, 0x800d0000,  0x000,  0x000, 0xb6ca0800)
    TEST_ST_W(0x17331928, 0x800d0000,  0x000,  0x000, 0x17331928)
    TEST_ST_W(0x09537c5f, 0x800d0000,  0x000,  0x000, 0x09537c5f)
    TEST_ST_W(0x36964fd0, 0x800d0000,  0x000,  0x000, 0x36964fd0)
    TEST_ST_W(0xe67b1aa6, 0x800d0000,  0x000,  0x000, 0xe67b1aa6)
    TEST_ST_W(0x00000000, 0x800d0000,  0x000,  0x000, 0x00000000)

###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addi.w s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    slli.w t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    st.w t0, s1, 0
    jirl zero, ra, 0
    nop
END(n15_st_w_test)
